package com.huixuebao.pay.service.Impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huixuebao.common.bean.ApiResult;
import com.huixuebao.pay.dto.PayOrderDTO;
import com.huixuebao.pay.entity.PayOrderEntity;
import com.huixuebao.pay.mapper.PayOrderMapper;
import com.huixuebao.pay.service.PayOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 根据保单查询支付详情
 */
@Service
public class PayOrderServiceImpl implements PayOrderService {

    @Autowired
    PayOrderMapper payOrderMapper;
    @Override
    public ApiResult settleDetails(String policyId) {
        ApiResult apiResult = new ApiResult();

        PayOrderEntity payOrderDetails = payOrderMapper.selectOne(new LambdaQueryWrapper<PayOrderEntity>().eq(PayOrderEntity::getPolicyId,policyId));
        PayOrderDTO payOrderDTO = new PayOrderDTO();
        payOrderDTO.setPolicyId(payOrderDetails.getPolicyId());
        payOrderDTO.setChannelOrderId(payOrderDetails.getChannelOrderId());
        payOrderDTO.setPayPrice(payOrderDetails.getPayPrice());
        payOrderDTO.setCoursePrice(payOrderDetails.getCoursePrice());
        payOrderDTO.setCreateTime(payOrderDetails.getCreateTime());
        payOrderDTO.setPayTime(payOrderDetails.getPayTime());
        apiResult.setData(payOrderDTO);

        return apiResult;
    }
}
